package Shop;
import java.lang.System;
import java.util.Scanner;
class Menu {
	 public void Menu(){
		 
	 }	 
     private void MainMenu(){	 
		 System.out.println("================================================");
		 System.out.println("             Welcome to ShoppingMall            ");
		 System.out.println("================================================");
		 System.out.println("          1. Please login first!                ");
		 System.out.println("          2. What do you want to search!        ");
		 System.out.println("          3. I want to see all goods!           ");
		 System.out.println("          4. My ShoppingCart!                   ");
		 System.out.println("          5. Exit!                              ");
		 System.out.println("================================================");
		 System.out.println(" Please make your choice:                       ");
		 System.out.println("================================================");
		 Scanner in = new Scanner(System.in);
	     while(in.hasNext()){
	         int x = in.nextInt();
	         switch (x) {
				case 1: LoginMenu();
					    break;
				case 2:	SearchMenu();
						break;
				case 3: SearchMenu();
					    break;
				case 4: System.out.println("Sorry!Please login first!");
					    break;
				case 5: System.out.println("Thanks for your coming! Welcome to your next!");
                        break;				
				default: System.out.println("You make a wrong choice. Please makea a new choice!");
					     ShopMenu();
		     }
	     }
	 }
	 private void LoginMenu() {
		    Scanner in = new Scanner(System.in);
			System.out.println("================================================");
			System.out.println("           Welcome to the Login screen          ");
			System.out.println("================================================");
			System.out.println("     username:                                  ");
			System.out.println("------------------------------------------------");
			System.out.println("     password:                                  ");
			System.out.println("================================================");
			System.out.println("                     OK!                        "); 
			System.out.println("================================================");
			String us = in.nextLine();
			String pa = in.nextLine();
			if(Login(us,pa) == 1)  ShopMenu();
		 }
	 private void SearchMenu(){
		    System.out.println("================================================");
			System.out.println("          Welcome to the Search screen          ");
			System.out.println("================================================");
			System.out.println("        1. Search something!                    ");
			System.out.println("        2. Show me all goods!                   ");
			System.out.println("        3. Exit!                                ");
			System.out.println("================================================");
			System.out.println(" Please make your choice:                       ");
			System.out.println("================================================");
		    Scanner in = new Scanner(System.in);
		    while(in.hasNext()){
			    int x = in.nextInt();  
			    switch (x) {
					case 1: System.out.println("================================================");
		           			System.out.println(" Search:                                        ");
						    System.out.println("================================================");
						    String str = in.nextLine();
					        Search(str);   break;
					case 2:	System.out.println("================================================");
	       			        System.out.println("| NAME | UNIT_PRICE | SALES_VOLUME | INTRODUCE |");
				            System.out.println("================================================");
				            ShowGoods();      break;
					case 3: ShopMenu();    break;
					default: System.out.println("You make a wrong choice. Please makea a new choice!");
				             ShopMenu();
			     }
			 }
		 }
	 private void ShoppingCartMenu() {
	     System.out.println("================================================");
		 System.out.println("       Welcome to your ShoppingCartMenu         ");
		 System.out.println("================================================");
		 System.out.println("          1. Goods_informations!                ");
		 System.out.println("          2. Clear the ShoppingCart!            ");
		 System.out.println("          3. Delete the goods!                  ");
		 System.out.println("          4. Final price!                       ");
		 System.out.println("          5. I want it!                         ");
		 System.out.println("          6. Exit                               ");
		 System.out.println("================================================");
	     System.out.println(" Please make your choice:                       ");
		 System.out.println("================================================");
		 Scanner in = new Scanner(System.in);
	     while(in.hasNext()){  
	    	 int x = in.nextInt();
			 switch (x) {
				case 1: ShowGoodsInformations();
						break;
				case 2: ClearAll();
						break;
				case 3: DeleteGoods();
						break;
				case 4: FinalPrice();
				        break;
				case 5: SettleAccounts();
					    break;
				case 6: ShopMenu();
				        break;
				default: System.out.println("You make a wrong choice. Please makea a new choice!");
					     ShoppingCartMenu();
		   	}
	     }
	 }	 
	 
	 private void ShopMenu() {
		 System.out.println("================================================");
		 System.out.println("             Welcome to ShoppingMall            ");
		 System.out.println("================================================");
		 System.out.println("          1. Show your informations!            ");
		 System.out.println("          2. What do you want to search!        ");
		 System.out.println("          3. I want to see all goods!           ");
		 System.out.println("          4. My ShoppingCart!                   ");
		 System.out.println("          5. Exit!                              ");
		 System.out.println("================================================");
		 System.out.println(" Please make your choice:                       ");
		 System.out.println("================================================");
		 Scanner in = new Scanner(System.in);
	     while(in.hasNext()){
	         int x = in.nextInt();
	         switch (x) {
				case 1: ShowCus();
					    break;
				case 2:	SearchMenu();
						break;
				case 3: SearchMenu();
					    break;
				case 4: ShoppingCartMenu();
					    break;
				case 5: MainMenu();
                        break;				
				default: System.out.println("You make a wrong choice. Please makea a new choice!");
					     ShopMenu();
		     }
	     }
     }
}
